\hypertarget{_tiny_r_c_8c}{
\section{TinyRC.c File Reference}
\label{_tiny_r_c_8c}\index{TinyRC.c@{TinyRC.c}}
}


TinyRC -\/ Smart RC controller.  


{\ttfamily \#include $<$avr/io.h$>$}\par
{\ttfamily \#include $<$avr/eeprom.h$>$}\par
{\ttfamily \#include $<$inttypes.h$>$}\par
{\ttfamily \#include $<$avr/interrupt.h$>$}\par
{\ttfamily \#include \char`\"{}tinyrc.h\char`\"{}}\par
{\ttfamily \#include \char`\"{}timer.h\char`\"{}}\par
\subsection*{Functions}
\begin{DoxyCompactItemize}
\item 
void \hyperlink{_tiny_r_c_8c_aeb2eb8ec1d703539637b101a4c278862}{LoadSettings} (void)
\begin{DoxyCompactList}\small\item\em Load settings from flasch. \item\end{DoxyCompactList}\item 
void \hyperlink{_tiny_r_c_8c_a147b338f5d58cbcc810148c89afa93f4}{InitPort} (void)
\begin{DoxyCompactList}\small\item\em Set port direction and state. \item\end{DoxyCompactList}\item 
void \hyperlink{_tiny_r_c_8c_a8210234a4d52931be1522bec8f5b0640}{InitPinChange} (void)
\begin{DoxyCompactList}\small\item\em Enables the Pin Change Interrupt. \item\end{DoxyCompactList}\item 
\hypertarget{_tiny_r_c_8c_aadde224169a9a944774b823da23c35cd}{
void {\bfseries PinChangeInterrupt} (void)}
\label{_tiny_r_c_8c_aadde224169a9a944774b823da23c35cd}

\item 
\hyperlink{_tiny_r_c_8c_aa64c6dce15e9de9105b4ae9533c9a267}{ISR} (PCINT0\_\-vect)
\begin{DoxyCompactList}\small\item\em pin change interrupt \item\end{DoxyCompactList}\item 
int \hyperlink{_tiny_r_c_8c_a840291bc02cba5474a4cb46a9b9566fe}{main} (void)
\begin{DoxyCompactList}\small\item\em Main function. \item\end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Variables}
\begin{DoxyCompactItemize}
\item 
\hypertarget{_tiny_r_c_8c_aeead39043ec99543f63199b658cb838d}{
uint16\_\-t \hyperlink{_tiny_r_c_8c_aeead39043ec99543f63199b658cb838d}{lastPCTime}}
\label{_tiny_r_c_8c_aeead39043ec99543f63199b658cb838d}

\begin{DoxyCompactList}\small\item\em lastPCTime \item\end{DoxyCompactList}\item 
\hypertarget{_tiny_r_c_8c_ae0a5118198891dfdfee6dd30639082a4}{
uint8\_\-t \hyperlink{_tiny_r_c_8c_ae0a5118198891dfdfee6dd30639082a4}{curCh} = 0}
\label{_tiny_r_c_8c_ae0a5118198891dfdfee6dd30639082a4}

\begin{DoxyCompactList}\small\item\em the current output channel \item\end{DoxyCompactList}\item 
\hypertarget{_tiny_r_c_8c_ac9c82413e828130c2b96705a79fb7cf0}{
uint8\_\-t \hyperlink{_tiny_r_c_8c_ac9c82413e828130c2b96705a79fb7cf0}{ch\_\-order\_\-in} \mbox{[}MAX\_\-IN\_\-CH\mbox{]}}
\label{_tiny_r_c_8c_ac9c82413e828130c2b96705a79fb7cf0}

\begin{DoxyCompactList}\small\item\em the order of input channels \item\end{DoxyCompactList}\item 
\hypertarget{_tiny_r_c_8c_a4c906d06a0594c2b96bc303a7dc7d866}{
uint8\_\-t \hyperlink{_tiny_r_c_8c_a4c906d06a0594c2b96bc303a7dc7d866}{ch\_\-order\_\-out} \mbox{[}MAX\_\-OUT\_\-CH\mbox{]}}
\label{_tiny_r_c_8c_a4c906d06a0594c2b96bc303a7dc7d866}

\begin{DoxyCompactList}\small\item\em the order channels to output \item\end{DoxyCompactList}\item 
\hypertarget{_tiny_r_c_8c_afa58776eed99e807c3d1f63aaabf3957}{
uint8\_\-t \hyperlink{_tiny_r_c_8c_afa58776eed99e807c3d1f63aaabf3957}{outState} = SEQU\_\-DELAY}
\label{_tiny_r_c_8c_afa58776eed99e807c3d1f63aaabf3957}

\begin{DoxyCompactList}\small\item\em state machine status for writing output \item\end{DoxyCompactList}\item 
\hypertarget{_tiny_r_c_8c_af61f3c22c9d41aa1ae1d1112438521cc}{
uint16\_\-t \hyperlink{_tiny_r_c_8c_af61f3c22c9d41aa1ae1d1112438521cc}{interChDelay} = 500}
\label{_tiny_r_c_8c_af61f3c22c9d41aa1ae1d1112438521cc}

\begin{DoxyCompactList}\small\item\em channel intermediate delay \item\end{DoxyCompactList}\item 
\hypertarget{_tiny_r_c_8c_aa3b033ac5ea44577435e55a9bc9b9974}{
uint16\_\-t {\bfseries sequDelay} = 10000}
\label{_tiny_r_c_8c_aa3b033ac5ea44577435e55a9bc9b9974}

\item 
\hypertarget{_tiny_r_c_8c_a236e38948425281f2f5a254d39b5fe51}{
uint16\_\-t \hyperlink{_tiny_r_c_8c_a236e38948425281f2f5a254d39b5fe51}{inData} \mbox{[}MAX\_\-OUT\_\-CH\mbox{]} = \{1000,1000,1000,1000,1000,1000,1000,1000\}}
\label{_tiny_r_c_8c_a236e38948425281f2f5a254d39b5fe51}

\begin{DoxyCompactList}\small\item\em input channel data \item\end{DoxyCompactList}\item 
\hypertarget{_tiny_r_c_8c_ab52e7a9f2c87dee80b7a5cc569189b85}{
uint8\_\-t \hyperlink{_tiny_r_c_8c_ab52e7a9f2c87dee80b7a5cc569189b85}{curInCh} = 0}
\label{_tiny_r_c_8c_ab52e7a9f2c87dee80b7a5cc569189b85}

\begin{DoxyCompactList}\small\item\em the current input channel \item\end{DoxyCompactList}\item 
\hypertarget{_tiny_r_c_8c_a5f28b75b6868790ce01e90b66d2c88ce}{
uint16\_\-t {\bfseries timeBuffer} \mbox{[}BUFFER\_\-IN\_\-SIZE\mbox{]}}
\label{_tiny_r_c_8c_a5f28b75b6868790ce01e90b66d2c88ce}

\item 
\hypertarget{_tiny_r_c_8c_a650e1fcede6a91dc05e4dc5035c52f0e}{
uint8\_\-t {\bfseries pinBuffer} \mbox{[}BUFFER\_\-IN\_\-SIZE\mbox{]}\mbox{[}2\mbox{]}}
\label{_tiny_r_c_8c_a650e1fcede6a91dc05e4dc5035c52f0e}

\item 
\hypertarget{_tiny_r_c_8c_a97723075678ec92a14507ef900543d51}{
uint8\_\-t {\bfseries writeBufferPos} = 0}
\label{_tiny_r_c_8c_a97723075678ec92a14507ef900543d51}

\item 
\hypertarget{_tiny_r_c_8c_a6c8871c2777b94c53c92c65524b17228}{
uint8\_\-t {\bfseries readBufferPos} = 0}
\label{_tiny_r_c_8c_a6c8871c2777b94c53c92c65524b17228}

\item 
\hypertarget{_tiny_r_c_8c_a851b1c189bac4f5142e681b10ec1eb55}{
uint8\_\-t {\bfseries timerHi}}
\label{_tiny_r_c_8c_a851b1c189bac4f5142e681b10ec1eb55}

\item 
\hypertarget{_tiny_r_c_8c_a4af746b1bb89f3bac6e04697ef7eda45}{
uint8\_\-t {\bfseries inState} = IN\_\-SEQU\_\-DELAY}
\label{_tiny_r_c_8c_a4af746b1bb89f3bac6e04697ef7eda45}

\item 
\hypertarget{_tiny_r_c_8c_a382dcd5543909cb04f4f4acb707f285a}{
uint16\_\-t {\bfseries lastTime}}
\label{_tiny_r_c_8c_a382dcd5543909cb04f4f4acb707f285a}

\item 
\hypertarget{_tiny_r_c_8c_ad5d10cf85bdd54a668921398512aa874}{
volatile uint8\_\-t $\ast$ {\bfseries outPort} \mbox{[}MAX\_\-OUT\_\-CH\mbox{]}}
\label{_tiny_r_c_8c_ad5d10cf85bdd54a668921398512aa874}

\item 
\hypertarget{_tiny_r_c_8c_a20b79355c07a7c4443576442715dc40a}{
uint8\_\-t {\bfseries outBit} \mbox{[}MAX\_\-OUT\_\-CH\mbox{]}}
\label{_tiny_r_c_8c_a20b79355c07a7c4443576442715dc40a}

\item 
\hypertarget{_tiny_r_c_8c_a6853467fd95c31667839585fb4aed6c6}{
volatile uint8\_\-t $\ast$ {\bfseries inPin} \mbox{[}MAX\_\-IN\_\-CH\mbox{]}}
\label{_tiny_r_c_8c_a6853467fd95c31667839585fb4aed6c6}

\item 
\hypertarget{_tiny_r_c_8c_ad3be198e94d1df4fa7b6708af8b591cf}{
uint8\_\-t {\bfseries inBit} \mbox{[}MAX\_\-IN\_\-CH\mbox{]}}
\label{_tiny_r_c_8c_ad3be198e94d1df4fa7b6708af8b591cf}

\item 
\hypertarget{_tiny_r_c_8c_a332122adb5128b11b69d24ad52f5c175}{
uint16\_\-t {\bfseries outData} \mbox{[}MAX\_\-OUT\_\-CH\mbox{]} = \{1000,1000,1000,1000,1000,1000,1000,1000\}}
\label{_tiny_r_c_8c_a332122adb5128b11b69d24ad52f5c175}

\item 
\hypertarget{_tiny_r_c_8c_aab331282c7205196e1a1429d444d6766}{
uint8\_\-t {\bfseries inSequ} \mbox{[}MAX\_\-IN\_\-CH\mbox{]} = \{4,0,3,2,5,1,7,6\}}
\label{_tiny_r_c_8c_aab331282c7205196e1a1429d444d6766}

\item 
\hypertarget{_tiny_r_c_8c_a58abc5b55ae43af17085c008cada27a0}{
uint8\_\-t {\bfseries outSequ} \mbox{[}MAX\_\-OUT\_\-CH\mbox{]} = \{0,1,2,3,4,5,6,7\}}
\label{_tiny_r_c_8c_a58abc5b55ae43af17085c008cada27a0}

\end{DoxyCompactItemize}


\subsection{Detailed Description}
TinyRC -\/ Smart RC controller. TinyRC is a smart RC controller board for mixing signal at the receiver side


\begin{DoxyItemize}
\item File: \hyperlink{_tiny_r_c_8c}{tinyrc.c}
\item Compiler: AVRGCC
\item Supported devices: ATTiny45
\end{DoxyItemize}

\begin{DoxyAuthor}{Author}
Stephan Harms email: \href{mailto:avr@stephanharms.de}{\tt avr@stephanharms.de}
\end{DoxyAuthor}
\begin{DoxyParagraph}{Name}
RELEASE\_\-1\_\-0 
\end{DoxyParagraph}
\begin{DoxyParagraph}{Revision}
1.0 
\end{DoxyParagraph}
\begin{DoxyParagraph}{RCSfile}
tinyrc,v 
\end{DoxyParagraph}
\begin{DoxyParagraph}{Date}
2007/11/20 
\end{DoxyParagraph}


\subsection{Function Documentation}
\hypertarget{_tiny_r_c_8c_a8210234a4d52931be1522bec8f5b0640}{
\index{TinyRC.c@{TinyRC.c}!InitPinChange@{InitPinChange}}
\index{InitPinChange@{InitPinChange}!TinyRC.c@{TinyRC.c}}
\subsubsection[{InitPinChange}]{\setlength{\rightskip}{0pt plus 5cm}void InitPinChange (void)}}
\label{_tiny_r_c_8c_a8210234a4d52931be1522bec8f5b0640}


Enables the Pin Change Interrupt. 

the function 'InitPinChange' is executed during startup it enables the pin change interrupt


\begin{DoxyParams}{Parameters}
\item[{\em none}]\end{DoxyParams}
\begin{DoxyReturn}{Returns}
none 
\end{DoxyReturn}
\hypertarget{_tiny_r_c_8c_a147b338f5d58cbcc810148c89afa93f4}{
\index{TinyRC.c@{TinyRC.c}!InitPort@{InitPort}}
\index{InitPort@{InitPort}!TinyRC.c@{TinyRC.c}}
\subsubsection[{InitPort}]{\setlength{\rightskip}{0pt plus 5cm}void InitPort (void)}}
\label{_tiny_r_c_8c_a147b338f5d58cbcc810148c89afa93f4}


Set port direction and state. 

the function 'InitPort' is executed during startup it sets the DD and PORT bits


\begin{DoxyParams}{Parameters}
\item[{\em none}]\end{DoxyParams}
\begin{DoxyReturn}{Returns}
none 
\end{DoxyReturn}
\hypertarget{_tiny_r_c_8c_aa64c6dce15e9de9105b4ae9533c9a267}{
\index{TinyRC.c@{TinyRC.c}!ISR@{ISR}}
\index{ISR@{ISR}!TinyRC.c@{TinyRC.c}}
\subsubsection[{ISR}]{\setlength{\rightskip}{0pt plus 5cm}ISR (PCINT0\_\-vect)}}
\label{_tiny_r_c_8c_aa64c6dce15e9de9105b4ae9533c9a267}


pin change interrupt 

the ISR 'PinCange0' is executed on a pin change of all pin of port ? on which the ?? is set


\begin{DoxyParams}{Parameters}
\item[{\em none}]\end{DoxyParams}
\begin{DoxyReturn}{Returns}
none 
\end{DoxyReturn}
\hypertarget{_tiny_r_c_8c_aeb2eb8ec1d703539637b101a4c278862}{
\index{TinyRC.c@{TinyRC.c}!LoadSettings@{LoadSettings}}
\index{LoadSettings@{LoadSettings}!TinyRC.c@{TinyRC.c}}
\subsubsection[{LoadSettings}]{\setlength{\rightskip}{0pt plus 5cm}void LoadSettings (void)}}
\label{_tiny_r_c_8c_aeb2eb8ec1d703539637b101a4c278862}


Load settings from flasch. 

the function 'LoadSettings' is executed during startup it reads settings from flash memory


\begin{DoxyParams}{Parameters}
\item[{\em none}]\end{DoxyParams}
\begin{DoxyReturn}{Returns}
none 
\end{DoxyReturn}
\hypertarget{_tiny_r_c_8c_a840291bc02cba5474a4cb46a9b9566fe}{
\index{TinyRC.c@{TinyRC.c}!main@{main}}
\index{main@{main}!TinyRC.c@{TinyRC.c}}
\subsubsection[{main}]{\setlength{\rightskip}{0pt plus 5cm}int main (void)}}
\label{_tiny_r_c_8c_a840291bc02cba5474a4cb46a9b9566fe}


Main function. 

The main loop checks for key input used timers are auto-\/updated in interrupt routines 